package org.pluslibs.framework.swingplus.utils;

import java.awt.event.KeyEvent;

public class KeyEventUtils {

    public static boolean isAlphaNumeric(int keyCode){
        if(isNumeric(keyCode)) return true;
        if(isAlpha(keyCode))return true;
        return false;
    }
    
    public static boolean isAlphaNumericSymbolic(int keyCode){
        if(isAlphaNumeric(keyCode))return true;
        if(isSymbol(keyCode))return true;
        return false;
    }
    
	public static int getFunctionKeyNumber(int keycode) {
		switch ( keycode ) {
			case KeyEvent.VK_F1: return 1;
			case KeyEvent.VK_F2: return 2;
			case KeyEvent.VK_F3: return 3;
			case KeyEvent.VK_F4: return 4;
			case KeyEvent.VK_F5: return 5;
			case KeyEvent.VK_F6: return 6;
			case KeyEvent.VK_F7: return 7;
			case KeyEvent.VK_F8: return 8;
			case KeyEvent.VK_F9: return 9;
			case KeyEvent.VK_F10: return 10;
			case KeyEvent.VK_F11: return 11;
			case KeyEvent.VK_F12: return 12;
			case KeyEvent.VK_F13: return 13;
			case KeyEvent.VK_F14: return 14;
			case KeyEvent.VK_F15: return 15;
			case KeyEvent.VK_F16: return 16;
			case KeyEvent.VK_F17: return 17;
			case KeyEvent.VK_F18: return 18;
			case KeyEvent.VK_F19: return 19;
			case KeyEvent.VK_F20: return 20;
			case KeyEvent.VK_F21: return 21;
			case KeyEvent.VK_F22: return 22;
			case KeyEvent.VK_F23: return 23;
			case KeyEvent.VK_F24: return 24;
			default: return -1;
		}
	}
	
	
	public static boolean isNumeric(int keyCode){
	    switch (keyCode) {
    	    case KeyEvent.VK_0: break;
    	    case KeyEvent.VK_1: break;
    	    case KeyEvent.VK_2: break;
    	    case KeyEvent.VK_3: break;
    	    case KeyEvent.VK_4: break;
    	    case KeyEvent.VK_5: break;
    	    case KeyEvent.VK_6: break;
    	    case KeyEvent.VK_7: break;
    	    case KeyEvent.VK_8: break;
    	    case KeyEvent.VK_9: break;
    	    default:return false;
	    }
	    return true;
	}
	
	public static boolean isAlpha(int keyCode){
	    switch (keyCode) {
    	    case KeyEvent.VK_A: break;
            case KeyEvent.VK_B: break;
            case KeyEvent.VK_C: break;
            case KeyEvent.VK_D: break;
            case KeyEvent.VK_E: break;
            case KeyEvent.VK_F: break;
            case KeyEvent.VK_G: break;
            case KeyEvent.VK_H: break;
            case KeyEvent.VK_I: break;
            case KeyEvent.VK_J: break;
            case KeyEvent.VK_K: break;
            case KeyEvent.VK_L: break;
            case KeyEvent.VK_M: break;
    	    case KeyEvent.VK_N: break;
    	    case KeyEvent.VK_O: break;
    	    case KeyEvent.VK_P: break;
    	    case KeyEvent.VK_Q: break;
    	    case KeyEvent.VK_R: break;
    	    case KeyEvent.VK_S: break;
    	    case KeyEvent.VK_T: break;
    	    case KeyEvent.VK_U: break;
    	    case KeyEvent.VK_V: break;
    	    case KeyEvent.VK_W: break;
    	    case KeyEvent.VK_X: break;
    	    case KeyEvent.VK_Y: break;
    	    case KeyEvent.VK_Z: break;
    	    default:return false;
	    }
	    return true;
	}
	
	public static boolean isSymbol(int keyCode){
	    switch (keyCode) {
    	    case KeyEvent.VK_AMPERSAND: break;
    	    case KeyEvent.VK_ASTERISK: break;
    	    case KeyEvent.VK_BACK_QUOTE: break;
    	    case KeyEvent.VK_BACK_SLASH: break;
    	    case KeyEvent.VK_BRACELEFT: break;
    	    case KeyEvent.VK_BRACERIGHT: break;
    	    case KeyEvent.VK_CIRCUMFLEX: break;
    	    case KeyEvent.VK_CLOSE_BRACKET: break;
    	    case KeyEvent.VK_COLON: break;
    	    case KeyEvent.VK_COMMA: break;
    	    case KeyEvent.VK_DOLLAR: break;
    	    case KeyEvent.VK_EQUALS: break;
    	    case KeyEvent.VK_EURO_SIGN: break;
    	    case KeyEvent.VK_EXCLAMATION_MARK: break;
    	    case KeyEvent.VK_INVERTED_EXCLAMATION_MARK: break;
    	    case KeyEvent.VK_LEFT_PARENTHESIS: break;
    	    case KeyEvent.VK_MINUS: break;
    	    case KeyEvent.VK_NUMBER_SIGN: break;
    	    case KeyEvent.VK_OPEN_BRACKET: break;
    	    case KeyEvent.VK_PERIOD: break;
    	    case KeyEvent.VK_PLUS: break;
    	    case KeyEvent.VK_QUOTE: break;
    	    case KeyEvent.VK_QUOTEDBL: break;
    	    case KeyEvent.VK_RIGHT_PARENTHESIS: break;
    	    case KeyEvent.VK_SLASH: break;
    	    case KeyEvent.VK_SEMICOLON: break;
    	    case KeyEvent.VK_UNDERSCORE: break;
    	    default:return false;
	    }
	    return true;
	}
	
	public static boolean isWhiteSpace(int keyCode){
	    switch (keyCode) {
    	    case KeyEvent.VK_ENTER: break;
    	    case KeyEvent.VK_SPACE: break;
    	    case KeyEvent.VK_TAB: break;
    	    default:return false;
	    }
	    return true;
	}
	
	public static boolean isCommandKey(int keyCode){
	    switch (keyCode) {
	    case KeyEvent.VK_ALT: break;
	    case KeyEvent.VK_ALT_GRAPH: break;
	    case KeyEvent.VK_CONTROL: break;
	    case KeyEvent.VK_WINDOWS: break;
	    case KeyEvent.VK_ESCAPE: break;	    
	    default:return false;
	    }
	    return true;
	}
	public static boolean isNumKey(int keyCode){
	    switch (keyCode) {
	    case KeyEvent.VK_DIVIDE: break;	    
	    case KeyEvent.VK_MULTIPLY: break;
	    case KeyEvent.VK_SUBTRACT: break;
	    case KeyEvent.VK_ADD: break;
	    case KeyEvent.VK_DECIMAL: break;	    
	    case KeyEvent.VK_NUMPAD0: break;	    
	    case KeyEvent.VK_NUMPAD1: break;	    
	    case KeyEvent.VK_NUMPAD2: break;	    
	    case KeyEvent.VK_NUMPAD3: break;	    
	    case KeyEvent.VK_NUMPAD4: break;	    
	    case KeyEvent.VK_NUMPAD5: break;	    
	    case KeyEvent.VK_NUMPAD6: break;	    
	    case KeyEvent.VK_NUMPAD7: break;	    
	    case KeyEvent.VK_NUMPAD8: break;	    
	    case KeyEvent.VK_NUMPAD9: break;	    
	    default:return false;
	    }
	    return true;
	}
}
